package com.loveprogrammer.eternity.skill.support.skills;

import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.enums.AttackTypeEnum;
import com.loveprogrammer.eternity.enums.QualityEnum;
import com.loveprogrammer.eternity.enums.WeaponTypeEnum;
import com.loveprogrammer.eternity.factory.MonsterFactory;
import com.loveprogrammer.eternity.factory.template.MonsterTemplate;
import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.Monster;
import com.loveprogrammer.eternity.model.attack.AttackEntity;
import com.loveprogrammer.eternity.model.attack.AttackResult;
import com.loveprogrammer.eternity.skill.support.skills.AbstractSkill;
import com.loveprogrammer.eternity.skill.support.states.ArmourReductionState;
import com.loveprogrammer.eternity.skill.support.states.BurnState;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @version 1.0.0
 * @description: TODO
 * @author: eric
 * @date: 2023-03-14 20:06
 **/
public class SkillCall extends AbstractSkill {

    public SkillCall(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    public boolean check(Character character) {
        if(character instanceof Monster){
            return true;
        }
        // 检查是否持有杖类武器
        return checkWeaponType(character, WeaponTypeEnum.WAND);
    }

    @Override
    public int opportunityPassive() {
        return 0;
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每5级升一级
        if(characterLevel % 5 == 0){
            return true;
        }
        return false;
    }

    @Override
    protected Tuple<String, List<Character>> skillLaunch(Character character, List<? extends Character> attack, List<? extends Character> defences) {
        Tuple<String, List<Character>> result = new Tuple<>();
        StringBuilder builder = new StringBuilder();

        MonsterTemplate template = MonsterFactory.getById(280);
        QualityEnum qualityEnum;
        if(getLevel() < 3){
            qualityEnum = QualityEnum.蓝色;
        }else if(getLevel() >= 3 && getLevel() < 6){
            qualityEnum = QualityEnum.黄色;
        }else if(getLevel() >= 6 && getLevel() < 9){
            qualityEnum = QualityEnum.紫色;
        }else{
            qualityEnum = QualityEnum.红色;
        }

        Monster monster = MonsterFactory.createMonster(template,character.getLevel(), qualityEnum,true);
        notify.publishCallEvent(monster,attack,15);
        builder.append("召唤骷髅王");
        result.setValue(new ArrayList<>());
        result.setKey(builder.toString());
        return result;
    }

    @Override
    protected int computeHarm(Character character) {
        return 0;
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }
}
